from bs4 import BeautifulSoup

from 爬虫.淘票票 import headers

soup = BeautifulSoup(open('test.html', encoding="utf-8"),"lxml")
print(soup.a)
print(soup.a.attrs)
print(soup.a.attrs['href'])

url="https://www.zut.edu.cn/index/tzgg1.htm"
import urllib.request

headers={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"
}
request = urllib.request.Request(url, headers=headers)
urlopen = urllib.request.urlopen(request)
urllib_data = urlopen.read().decode("utf-8")
# print(urllib_data)
with open("中原工学院.html","w",encoding="utf-8") as fp:
    fp.write(urllib_data)

soup = BeautifulSoup(open("中原工学院.html","r",encoding="utf-8"),"lxml")
find_all = soup.find_all("a", class_="nav-list-two-nav-item")
for i in find_all:
    print(i.text)
